<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>tango.text.stream.StreamIterator</title>
  <link href="./css/style.css" rel="stylesheet" type="text/css"/>
  <!-- <link href="./img/icon.png" rel="icon" type="image/png"/> -->
  <script type="text/javascript" src="./js/jquery.js"></script>
  <script type="text/javascript" src="./js/modules.js"></script>
  <script type="text/javascript" src="./js/quicksearch.js"></script>
  <script type="text/javascript" src="./js/navigation.js"></script>
  <!--<script type="text/javascript" src="./js/jquery.treeview.js"></script>-->
  <script type="text/javascript">
    var g_moduleFQN = "tango.text.stream.StreamIterator";
  </script>
  
</head>
<body>
<div id="content">
  <h1><a href="./htmlsrc/tango.text.stream.StreamIterator.html" class="symbol">tango.text.stream.StreamIterator</a></h1>
  
<p class="sec_header">License:</p>BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a>
<p class="sec_header">Version:</p>Initial release: December 2005
<p class="sec_header">Author:</p>Kris
<dl>
<dt class="decl">class <a class="symbol _class" name="StreamIterator" href="./htmlsrc/tango.text.stream.StreamIterator.html#L55" kind="class" beg="55" end="386">StreamIterator</a><span class="tparams">(T)</span> : InputStream, Buffered; <a title="Permalink to this symbol" href="#StreamIterator" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L55">#</a></dt>
<dd class="ddef">
<div class="summary">The base class for a set of stream iterators. These operate
        upon a buffered input stream, and are designed to deal with
        partial content. That is, stream iterators go to work the
        moment any data becomes available in the buffer. Contrast
        this behaviour with the tango.text.Util iterators, which
        operate upon the extent of an array.</div>
There are two types of iterators supported; exclusive and
        inclusive. The former are the more common kind, where a token
        is delimited by elements that are considered foreign. Examples
        include space, comma, and end-of-line delineation. Inclusive
        tokens are just the opposite: they look for patterns in the
        text that should be part of the token itself - everything else
        is considered foreign. Currently tango.text.stream includes the
        exclusive variety only.
<p class="bl"/>
        Each pattern is exposed to the client as a slice of the original
        content, where the slice is transient. If you need to retain the
        exposed content, then you should .dup it appropriately. 
<p class="bl"/>
        The content provided to these iterators is intended to be fully
        read-only. All current tokenizers abide by this rule, but it is
        possible a user could mutate the content through a token slice.
        To enforce the desired read-only aspect, the code would have to
        introduce redundant copying or the compiler would have to support
        read-only arrays.
<p class="bl"/>
        See LineIterator, CharIterator, RegexIterator, QuotedIterator,
        and SimpleIterator
<dl>
<dt class="decl">uint <a class="symbol _function" name="StreamIterator.scan" href="./htmlsrc/tango.text.stream.StreamIterator.html#L67" kind="function" beg="67" end="67">scan</a><span class="params">(void[] <em>data</em>)</span>; <span class="attrs">[<span class="prot">protected</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.scan" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L67">#</a></dt>
<dd class="ddef">
<div class="summary">The pattern scanner, implemented via subclasses</div></dd>
<dt class="decl"><a class="symbol _ctor" name="StreamIterator.this" href="./htmlsrc/tango.text.stream.StreamIterator.html#L75" kind="ctor" beg="75" end="79">this</a><span class="params">(InputStream <em>stream</em> = null)</span>; <a title="Permalink to this symbol" href="#StreamIterator.this" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L75">#</a></dt>
<dd class="ddef">
<div class="summary">Instantiate with a buffer</div></dd>
<dt class="decl">StreamIterator <a class="symbol _function" name="StreamIterator.set" href="./htmlsrc/tango.text.stream.StreamIterator.html#L87" kind="function" beg="87" end="92">set</a><span class="params">(InputStream <em>stream</em>)</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.set" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L87">#</a></dt>
<dd class="ddef">
<div class="summary">Set the provided stream as the scanning source</div></dd>
<dt class="decl">T[] <a class="symbol _function" name="StreamIterator.get" href="./htmlsrc/tango.text.stream.StreamIterator.html#L100" kind="function" beg="100" end="103">get</a><span class="params">()</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.get" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L100">#</a></dt>
<dd class="ddef">
<div class="summary">Return the current token as a slice of the content</div></dd>
<dt class="decl">StreamIterator <a class="symbol _function" name="StreamIterator.push" href="./htmlsrc/tango.text.stream.StreamIterator.html#L114" kind="function" beg="114" end="117">push</a><span class="params">(T[] <em>token</em>)</span>; <span class="attrs">[<span class="stc">final</span>, <span class="stc">deprecated</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.push" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L114">#</a></dt>
<dd class="ddef">
<div class="summary">Push one token back into the stream, to be returned by a
                subsequent call to next()</div>
Push null to cancel a prior assignment</dd>
<dt class="decl">int <a class="symbol _function" name="StreamIterator.opApply" href="./htmlsrc/tango.text.stream.StreamIterator.html#L127" kind="function" beg="127" end="137">opApply</a><span class="params">(int delegate(inout T[]) <em>dg</em>)</span>; <a title="Permalink to this symbol" href="#StreamIterator.opApply" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L127">#</a></dt>
<dd class="ddef">
<div class="summary">Iterate over the set of tokens. This should really
                provide read-only access to the tokens, but D does
                not support that at this time</div></dd>
<dt class="decl">int <a class="symbol _function" name="StreamIterator.opApply:2" href="./htmlsrc/tango.text.stream.StreamIterator.html#L146" kind="function" beg="146" end="158">opApply</a><span class="params">(int delegate(inout int, inout T[]) <em>dg</em>)</span>; <a title="Permalink to this symbol" href="#StreamIterator.opApply:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L146">#</a></dt>
<dd class="ddef">
<div class="summary">Iterate over a set of tokens, exposing a token count 
                starting at zero</div></dd>
<dt class="decl">int <a class="symbol _function" name="StreamIterator.opApply:3" href="./htmlsrc/tango.text.stream.StreamIterator.html#L167" kind="function" beg="167" end="180">opApply</a><span class="params">(int delegate(inout int, inout T[], inout T[]) <em>dg</em>)</span>; <a title="Permalink to this symbol" href="#StreamIterator.opApply:3" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L167">#</a></dt>
<dd class="ddef">
<div class="summary">Iterate over a set of tokens and delimiters, exposing a 
                token count starting at zero</div></dd>
<dt class="decl">T[] <a class="symbol _function" name="StreamIterator.next" href="./htmlsrc/tango.text.stream.StreamIterator.html#L208" kind="function" beg="208" end="213">next</a><span class="params">()</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.next" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L208">#</a></dt>
<dd class="ddef">
<div class="summary">Locate the next token. Returns the token if found, null
                otherwise. Null indicates an end of stream condition. To
                sweep a conduit for lines using method next():
                <pre class="d_code">
<span class="k">auto</span> <span class="i">lines</span> = <span class="k">new</span> <span class="i">LineIterator</span>!(<span class="k">char</span>) (<span class="k">new</span> <span class="i">FileConduit</span>(<span class="sl">"myfile"</span>));
<span class="k">while</span> (<span class="i">lines</span>.<span class="i">next</span>)
       <span class="i">Cout</span> (<span class="i">lines</span>.<span class="i">get</span>).<span class="i">newline</span>;
</pre></div>
Alternatively, we can extract one line from a conduit:
                <pre class="d_code">
<span class="k">auto</span> <span class="i">line</span> = (<span class="k">new</span> <span class="i">LineIterator</span>!(<span class="k">char</span>) (<span class="k">new</span> <span class="i">FileConduit</span>(<span class="sl">"myfile"</span>))).<span class="i">next</span>;
</pre>
<p class="bl"/>
                The difference between next() and foreach() is that the
                latter processes all tokens in one go, whereas the former
                processes in a piecemeal fashion. To wit:
                <pre class="d_code">
<span class="k">foreach</span> (<span class="i">line</span>; <span class="k">new</span> <span class="i">LineIterator</span>!(<span class="k">char</span>) (<span class="k">new</span> <span class="i">FileConduit</span>(<span class="sl">"myfile"</span>)))
         <span class="i">Cout</span>(<span class="i">line</span>).<span class="i">newline</span>;
</pre></dd>
<dt class="decl">uint <a class="symbol _function" name="StreamIterator.set:2" href="./htmlsrc/tango.text.stream.StreamIterator.html#L222" kind="function" beg="222" end="226">set</a><span class="params">(T* <em>content</em>, uint <em>start</em>, uint <em>end</em>)</span>; <span class="attrs">[<span class="prot">protected</span>, <span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.set:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L222">#</a></dt>
<dd class="ddef">
<div class="summary">Set the content of the current slice to the provided 
                start and end points</div></dd>
<dt class="decl">uint <a class="symbol _function" name="StreamIterator.set:3" href="./htmlsrc/tango.text.stream.StreamIterator.html#L236" kind="function" beg="236" end="241">set</a><span class="params">(T* <em>content</em>, uint <em>start</em>, uint <em>end</em>, uint <em>next</em>)</span>; <span class="attrs">[<span class="prot">protected</span>, <span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.set:3" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L236">#</a></dt>
<dd class="ddef">
<div class="summary">Set the content of the current slice to the provided 
                start and end points, and delimiter to the segment
                between end &amp; next (inclusive)</div></dd>
<dt class="decl">uint <a class="symbol _function" name="StreamIterator.notFound" href="./htmlsrc/tango.text.stream.StreamIterator.html#L251" kind="function" beg="251" end="254">notFound</a><span class="params">()</span>; <span class="attrs">[<span class="prot">protected</span>, <span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.notFound" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L251">#</a></dt>
<dd class="ddef">
<div class="summary">Called when a scanner fails to find a matching pattern.
                This may cause more content to be loaded, and a rescan
                initiated</div></dd>
<dt class="decl">uint <a class="symbol _function" name="StreamIterator.found" href="./htmlsrc/tango.text.stream.StreamIterator.html#L265" kind="function" beg="265" end="268">found</a><span class="params">(uint <em>i</em>)</span>; <span class="attrs">[<span class="prot">protected</span>, <span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.found" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L265">#</a></dt>
<dd class="ddef">
<div class="summary">Invoked when a scanner matches a pattern. The provided
                value should be the index of the last element of the
                matching pattern, which is converted back to a void[]
                index.</div></dd>
<dt class="decl">bool <a class="symbol _function" name="StreamIterator.has" href="./htmlsrc/tango.text.stream.StreamIterator.html#L276" kind="function" beg="276" end="282">has</a><span class="params">(T[] <em>set</em>, T <em>match</em>)</span>; <span class="attrs">[<span class="prot">protected</span>, <span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.has" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L276">#</a></dt>
<dd class="ddef">
<div class="summary">See if set of characters holds a particular instance</div></dd>
<dt class="decl">bool <a class="symbol _function" name="StreamIterator.consume" href="./htmlsrc/tango.text.stream.StreamIterator.html#L291" kind="function" beg="291" end="299">consume</a><span class="params">()</span>; <span class="attrs">[<span class="prot">private</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.consume" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L291">#</a></dt>
<dd class="ddef">
<div class="summary">Consume the next token and place it in 'slice'. Returns 
                true when there are potentially more tokens</div></dd>
<dt class="decl">IBuffer <a class="symbol _function" name="StreamIterator.buffer" href="./htmlsrc/tango.text.stream.StreamIterator.html#L313" kind="function" beg="313" end="316">buffer</a><span class="params">()</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.buffer" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L313">#</a></dt>
<dd class="ddef">
<div class="summary">Buffered Interface</div>
Return the associated buffer</dd>
<dt class="decl">IConduit <a class="symbol _function" name="StreamIterator.conduit" href="./htmlsrc/tango.text.stream.StreamIterator.html#L329" kind="function" beg="329" end="332">conduit</a><span class="params">()</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.conduit" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L329">#</a></dt>
<dd class="ddef">
<div class="summary">InputStream Interface</div>
Return the host conduit</dd>
<dt class="decl">uint <a class="symbol _function" name="StreamIterator.read" href="./htmlsrc/tango.text.stream.StreamIterator.html#L344" kind="function" beg="344" end="347">read</a><span class="params">(void[] <em>dst</em>)</span>; <a title="Permalink to this symbol" href="#StreamIterator.read" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L344">#</a></dt>
<dd class="ddef">
<div class="summary">Read from conduit into a target array. The provided dst 
                will be populated with content from the conduit.</div>
Returns the number of bytes read, which may be less than
                requested in dst</dd>
<dt class="decl">void[] <a class="symbol _function" name="StreamIterator.load" href="./htmlsrc/tango.text.stream.StreamIterator.html#L360" kind="function" beg="360" end="363">load</a><span class="params">(void[] <em>dst</em> = null)</span>; <a title="Permalink to this symbol" href="#StreamIterator.load" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L360">#</a></dt>
<dd class="ddef">
<div class="summary">Load the bits from a stream, and return them all in an
                array. The dst array can be provided as an option, which
                will be expanded as necessary to consume the input.</div>
Returns an array representing the content, and throws
                IOException on error</dd>
<dt class="decl">InputStream <a class="symbol _function" name="StreamIterator.clear" href="./htmlsrc/tango.text.stream.StreamIterator.html#L371" kind="function" beg="371" end="374">clear</a><span class="params">()</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.clear" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L371">#</a></dt>
<dd class="ddef">
<div class="summary">Clear any buffered content</div></dd>
<dt class="decl">void <a class="symbol _function" name="StreamIterator.close" href="./htmlsrc/tango.text.stream.StreamIterator.html#L382" kind="function" beg="382" end="385">close</a><span class="params">()</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#StreamIterator.close" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.text.stream.StreamIterator.html#L382">#</a></dt>
<dd class="ddef">
<div class="summary">Close the input</div></dd></dl></dd></dl>
</div>
<div id="footer">
  <p>Copyright (c) 2004 Kris Bell. All rights reserved</p>
  <p>Page generated by <a href="http://code.google.com/p/dil">dil</a> on Fri Dec 26 04:04:42 2008. Rendered by <a href="http://code.google.com/p/dil/wiki/Kandil">kandil</a>.</p>
</div>
</body>
</html>